<template>
  <div style="margin-top:10px;">
    <el-table :data="categor.cateList" border style="width: 100%">
      <el-table-column prop="id" label="ID" min-width="80"></el-table-column>
      <el-table-column prop="name" label="商品名称"  min-width="80"></el-table-column>
      <el-table-column label="分类级别" min-width="80">
        <template slot-scope="scope">{{categor.cateList[scope.$index].level==1?'顶级分类':'子分类'}}</template>
      </el-table-column>
      <el-table-column label="图片" min-width="80">
        <template slot-scope="scope">
          <img :src="categor.cateList[scope.$index].wap_banner_url" style="width:90px;height:40px;"  alt />
        </template>
      </el-table-column>
      <el-table-column label="是否显示" min-width="80">
        <template slot-scope="scope">
            {{categor.cateList[scope.$index].is_show?'是':'否'}}</template>
      </el-table-column>
      <el-table-column label="排序" min-width="80">
        <template slot-scope="scope">{{categor.cateList[scope.$index].sort_order}}</template>
      </el-table-column>
      <el-table-column label="操作">
        <template slot-scope="scope">
          <el-button
            @click="deletelist(scope.$index,categor.cateList[scope.$index].id)"
            type="primary"
            size="small"
          >编辑</el-button>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
//引入vuex
import { mapState } from "vuex";

export default {
  computed: {
    ...mapState(["categor"])
  },
  created(){
      this.$store.dispatch('categor/categoryget')
  },
  //   方法
  methods: {
    deletelist(e, id) {
      console.log(e, id);
      this.$router.push({
        path:`/editcategory/${id}`,
        params:{
          id
        }
      })
    }
  }
};
</script>

<style>
</style>